//package tms.model;
//
//
//import static org.junit.Assert.assertEquals;
//import static org.junit.Assert.assertFalse;
//import static org.junit.Assert.assertNotNull;
//import static org.junit.Assert.assertNull;
//import static org.junit.Assert.assertTrue;
//
//import org.junit.Test;
//
///**
// * Perform dbUnit test	
// */
//public class DbManagerTest {
//
//    private static final String testTableName = "UnitTest";
//    private String[] columns = new String[] {"Note"};
//    private String[] values = new String[] {"'new note'"};
//
//    /**
//     * Table: UnitTest containing 2 records.
//     */
//    private void InitTestTable() {
//
//        DbManager.execute("drop table if exists UnitTest");
//        DbManager.execute("CREATE TABLE UnitTest (Id integer NOT NULL PRIMARY KEY AUTOINCREMENT, Note text)");
//        DbManager.execute("INSERT INTO UnitTest (Note) VALUES ('a note')");
//        DbManager.execute("INSERT INTO UnitTest (Note) VALUES ('another note')");
//    }
//
//    @Test
//    public void testOpenConnection() {
//
//        DbManager.closeConnection();
//        DbManager.openConnection();
//        assertNotNull(DbManager.getConnection());
//    }
//
//    @Test
//    public void testCloseConnection() {
//
//        DbManager.openConnection();
//        DbManager.closeConnection();
//        assertNull(DbManager.getConnection());
//    }
//
//    @Test
//    public void testGetFirstDynamic() {
//
//        InitTestTable();
//
//        assertNotNull(DbManager.getFirstDynamic(testTableName, "id = 1"));
//
//        //Execution with an invalid table name or where clause should return false
//        assertNull(DbManager.getFirstDynamic(testTableName, "this is not a valid where clause"));
//        assertNull(DbManager.getFirstDynamic("this is not a valid table name", ""));
//    }
//
//    @Test
//    public void testGetListDynamic() {
//
//        InitTestTable();
//
//        assertNotNull(DbManager.getListDynamic(testTableName, ""));
//        assertEquals(2, DbManager.getListDynamic(testTableName, "").size());
//
//        //Execution with an invalid table name or where clause should return false
//        assertEquals(DbManager.getListDynamic("testTableName", "this is not a valid where clause").size(), 0);
//        assertEquals(DbManager.getListDynamic("this is not a valid table name", "").size(), 0);
//    }
//
//    @Test
//    public void testInsert() {
//
//        InitTestTable();
//
//        //Table' size must be 2 before insertion
//        assertEquals(2, DbManager.getListDynamic(testTableName, "").size());
//
//        assertTrue(DbManager.insert(testTableName, columns, values));
//
//        //Table' size should be increased by 1 (= 3) after insertion
//        assertEquals(3, DbManager.getListDynamic(testTableName, "").size());
//
//        //Execution with an invalid table name should return false
//        assertFalse(DbManager.insert("this is not a valid table", columns, values));
//        assertFalse(DbManager.insert("", columns, values));
//    }
//
//    @Test
//    public void testUpdate() {
//
//        InitTestTable();
//
//        //Table' size must be 2 before update
//        assertEquals(2, DbManager.getListDynamic(testTableName, "").size());
//
//        assertTrue(DbManager.update(testTableName, columns, new String[] {"'an edited note'" }, ""));
//
//        //Table' size should not change (= 2) after update
//        assertEquals(2, DbManager.getListDynamic(testTableName, "").size());
//
//        //Execution with an invalid table name should return false
//        assertFalse(DbManager.update("this is not a valid table", columns, values, "id = 1"));
//    }
//
//    @Test
//    public void testDelete() {
//
//        InitTestTable();
//
//        //Table' size must be 2 before deletion
//        assertEquals(2, DbManager.getListDynamic(testTableName, "").size());
//
//        assertTrue(DbManager.delete(testTableName, "id = 1"));
//
//        //Table' size should be decreased by 1 (= 2) after deletion
//        assertEquals(1, DbManager.getListDynamic(testTableName, "").size());
//
//        assertTrue(DbManager.delete(testTableName, ""));
//
//        //Table' size should be 0 after deletion all item
//        assertEquals(0, DbManager.getListDynamic(testTableName, "").size());
//
//        //Execution with an invalid table name should return false
//        assertFalse(DbManager.delete("this is not a valid table name", ""));
//    }
//}
